#include <boost/serialization/map.hpp>
#include <boost/serialization/string.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <iostream>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <fstream>

using namespace std;

map<string, map<int, double> > u_map;

int main(int argc, char** argv){
  string s;
  string uid;
  int p_count;
  int n_count;

  while(getline(cin,s)){
    istringstream iss(s);
    iss >> uid;
    iss >> p_count;
    iss >> n_count;

    if(u_map.find(uid) == u_map.end()){
      u_map.insert(make_pair(uid, map<int,double>()));
      cout << endl << "added user " << uid;
    }

    map<int, double> & uid_map = u_map[uid];
    int t = p_count + n_count;
    double p = (double)p_count / (double) t;
    double n = (double)n_count / (double) t;

    uid_map.insert(make_pair(1,p));
    uid_map.insert(make_pair(-1,n));

  }

  cout << endl << "writing map ... ";

  ofstream ofs(argv[1], ios::binary);
  boost::archive::binary_oarchive oa(ofs);
  oa << u_map;
  
  return 0;
}
